

#pragma once

#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "baseClass\shader.h"
#include "baseClass\Texture2D.h"
#include "baseClass/Physical.h"
#include "geometry/BlockMesh.h"
#include "baseClass/Picture.h"
#include <unordered_map>
#include <Set>


enum BlockID
{
    GrassDirt = 0, //多种材质

    RoughStone = 1,
    Dirt = 2,
    Board = 4,

    Stone = 16,
    Bedrock,
    Sand,
    Gravel,
    OakWood,
    IronBlock = 22,
    GoldBlock,
    DiamondBlock,
    EmeraldBlock,
    RedStoneBlock,

    GoldMineral = 32,
    IronMineral,
    CoalMineral,

    Air = 999999999
};



class BlockBase
{
private:
static Texture2D* GetSingleTexture(BlockID id);

public:
    BlockID id = Air;
    uint8_t brightnessLevel[6] = {1,1,1,1,1,1};

    enum faceid
    {
        X  = 0B00000001,
        Y  = 0B00000010,
        Z  = 0B00000100,
        X_ = 0B00001000,
        Y_ = 0B00010000,
        Z_ = 0B00100000,
        ALL= 0B00111111
    };
    
    static Picture blockTerrainPic;
    static unordered_map<BlockID, unordered_map<uint32_t,Texture2D*>> BlockTexture;
    static vector<BlockVertex> faceVertex;

    static void DrawBlockline(glm::vec3 pos);

    unordered_map<Texture2D*,vector<BlockVertex>> GetfaceVandT(int face = ALL);
    vector<BlockVertex> GetfaceV(int face);

    //初始化函数
    static void LoadBlocksTexture();
    // static void RegistryBlocksTextureLoder();


    void SetBrightnessLevel_face(int face, uint8_t brightnessLevel);

    BlockBase(){};

    
    
    unordered_map<uint32_t,Texture2D*> GetTexture(); // 不同朝向的纹理 X,X_,Y,Y_,Z,Z_ 并保存在BlockTexture
    virtual  ~BlockBase(){};
};

class Air_Block : public BlockBase
{
public:
    Air_Block(){ id = Air; };
};

class Stone_Block : public BlockBase
{
public:
    Stone_Block(){ id = Stone; };
};

class RoughStone_Block : public BlockBase
{
public:
    RoughStone_Block(){ id = RoughStone; };
};

class Dirt_Block : public BlockBase
{
public:
    Dirt_Block(){ id = Dirt; };
};

class Board_Block : public BlockBase
{
public:
    Board_Block(){ id = Board; };
};

class Bedrock_Block : public BlockBase
{
public:
    Bedrock_Block(){ id = Bedrock; };
};


class Sand_Block : public BlockBase
{
public:
    Sand_Block(){ id = Sand; };
};


class Gravel_Block : public BlockBase
{
public:
    Gravel_Block(){ id = Gravel; };
};

class IronBlock_Block : public BlockBase
{
public:
    IronBlock_Block(){ id = IronBlock; };
};

class GoldBlock_Block : public BlockBase
{
public:
    GoldBlock_Block(){ id = GoldBlock; };
};

class DiamondBlock_Block : public BlockBase
{
public:
    DiamondBlock_Block(){ id = DiamondBlock; };
};

class EmeraldBlock_Block : public BlockBase
{
public:
    EmeraldBlock_Block(){ id = EmeraldBlock; };
};

class RedStoneBlock_Block : public BlockBase
{
public:
    RedStoneBlock_Block(){ id = RedStoneBlock; };
};

class GoldMineral_Block : public BlockBase
{
public:
    GoldMineral_Block(){ id = GoldMineral; };
};

class IronMineral_Block : public BlockBase
{
public:
    IronMineral_Block(){ id = IronMineral; };
};

class CoalMineral_Block : public BlockBase
{
public:
    CoalMineral_Block(){ id = CoalMineral; };
};


class OakWood_Block : public BlockBase
{
public:
    OakWood_Block(){ id = OakWood; };
    static unordered_map<uint32_t,Texture2D*> m_GetTexture() ; 
};


class GrassDirt_Block : public BlockBase
{
public:
    GrassDirt_Block(){ id = GrassDirt; };
    static unordered_map<uint32_t,Texture2D*> m_GetTexture(); 
};